package com.zsr.chapter03.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author zsr
 * @Description 用ServletConfig对象读取配置文件
 * @Version 1.0
 */
public class ServletDemo3 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取ServletConfig对象
        ServletConfig servletConfig = getServletConfig();
        //获取参数的值
        String value = servletConfig.getInitParameter("encoding");
        response.getWriter().print("encoding:"+value);
    }
}
